<template>
  <view>
    <wx-open-launch-weapp id="launch-btn" username="gh_b83594dfd921" path="pages/home/Index">
      <script type="text/wxtag-template">
  <style>.btn { padding: 12px }</style>
  <button class="btn">打开小程序</button>
      </script>
    </wx-open-launch-weapp>
  </view>
</template>
<script>
import wx from "jweixin-module";
export default {
  onLoad() {
    let url = window.location.href.split("#")[0]; //要在公众号平台设置JS接口安全域名，ip白名单
    uni.request({
      url: "https://oldm.51bmj.cn/WeiXin/GetClientSign",
      data: {
        rawUrl: url
      },
      dataType: "json",
      header: {
        "X-Requested-With": "XMLHttpRequest"
      },
      success: res => {
        if (res.statusCode == 200) {
          let { data } = res;
          wx.config({
            debug: false, // 开启调试模式,返回值会在客户端alert出来。
            appId: data.appId, // 必填，公众号的唯一标识
            timestamp: data.timestamp, // 必填，生成签名的时间戳
            nonceStr: data.nonceStr, // 必填，生成签名的随机串
            signature: data.signature, // 必填，签名，见微信开发文档附录1
            jsApiList: [
              "chooseImage",
              "previewImage",
              "updateAppMessageShareData",
              "updateTimelineShareData",
              "onMenuShareAppMessage",
              "onMenuShareTimeline"
            ],
            openTagList: ["wx-open-launch-weapp"] // 可选，需要使用的开放标签列表
          });
          wx.ready(function() {});
        }
      }
    });
  }
};
</script>